Skip to content

build: do not hardcode paths outside of $prefix#16998

Draft
intelfx wants to merge 3 commits intoopenzfs:masterfrom
intelfx:work/build-fix-paths
Draft

build: do not hardcode paths outside of $prefix#16998
intelfx wants to merge 3 commits intoopenzfs:masterfrom
intelfx:work/build-fix-paths

Conversation

@intelfx
Copy link
Contributor

@intelfx intelfx commented Jan 28, 2025

Motivation and Context

When making local builds of ZFS for debugging, it might be convenient to be able
to make several different builds of ZFS utils and install/run them side-by-side.

When doing so in process of debugging an unrelated change, I discovered that
even if configure is ran with --prefix= pointing to a user-writable directory,
make install always attempts to write some files to system-wide locations
(and thus fails without superuser privileges, not to mention the fact that you
generally do not want to overwrite system files with a dev build regardless).

Description

This fixes behavior of the build system when a prefix other than /usr
is provided.

Specifically, this change makes it possible to build ZFS utils with
--prefix= set to a user-writable directory (such as $HOME/...)
and successfully run make install without superuser privileges.

How Has This Been Tested?

  • build-tested on x86_64 Arch Linux
  • verified correctness of installation with prefix=/usr and prefix!=/usr

(NOTE: CI failures seem relevant, something seems to go wrong with other distros, I'll fix the problems but still would like a superficial review to confirm this is acceptable/reasonable)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@intelfx intelfx changed the title config: do not hardcode paths outside of $prefix build: do not hardcode paths outside of $prefix Jan 28, 2025
@amotin
Copy link
Member

amotin commented Jan 28, 2025

@intelfx Linux builders are quite unhappy.

@intelfx
Copy link
Contributor Author

intelfx commented Jan 28, 2025

@intelfx Linux builders are quite unhappy.

Yes, I'll fix this. I'm just putting this out here as a PR to run CI on it because it's easier than setting up all those distros locally.

@amotin
Copy link
Member

amotin commented Jan 28, 2025

I'm just putting this out here as a PR to run CI on it because it's easier than setting up all those distros locally.

OK. If it take longer, you could run CI in your own clone or mark the PR as draft.

@ixhamza
Copy link
Member

ixhamza commented Jan 28, 2025

@intelfx - In case you're not aware, you can see the same tests running for each of your pushes in the GitHub Actions for your repository: https://github.com/intelfx/zfs/actions.

@intelfx
Copy link
Contributor Author

intelfx commented Jan 28, 2025

@intelfx - In case you're not aware, you can see the same tests running for each of your pushes in the GitHub Actions for your repository: https://github.com/intelfx/zfs/actions.

Yes, I was not aware. I assumed that typically CI runs (especially heavyweight ones) are limited to the parent repository to avoid abuse, so this is unexpected.

@amotin
Copy link
Member

amotin commented Jan 28, 2025

I assumed that typically CI runs are limited to the parent repository to avoid abuse.

As I understand you would only abuse your own limits, unrelated to OpenZFS. You can control whether to run CI on pushes to your own clone in its settings. By default I think it is enabled.

@robn
Copy link
Member

robn commented Jan 29, 2025

@intelfx superficial review looks great. Another thing I've wanted/hacked up/been getting around to for ages. I'll be happy to give it a more in-depth review once you're done!

@behlendorf behlendorf added Component: Packaging custom packages Status: Code Review Needed Ready for review and testing labels Feb 24, 2025
@intelfx intelfx force-pushed the work/build-fix-paths branch from 406fa95 to a53814c Compare August 23, 2025 18:41
@intelfx intelfx marked this pull request as draft December 21, 2025 17:42
@github-actions github-actions bot added Status: Work in Progress Not yet ready for general review and removed Status: Code Review Needed Ready for review and testing labels Dec 21, 2025
This fixes behavior of the build system when a prefix other than `/usr`
is provided.

Specifically, this change makes it possible to build ZFS utils with
`--prefix=` set to a user-writable directory (such as `$HOME/...`)
and successfully run `make install` without superuser privileges.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
@intelfx intelfx force-pushed the work/build-fix-paths branch from a53814c to da75e1e Compare December 21, 2025 17:43
@intelfx intelfx force-pushed the work/build-fix-paths branch from 2ac5200 to 63b0356 Compare January 25, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Packaging custom packages Status: Work in Progress Not yet ready for general review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants